package com.shop.zzh.config;

import com.mongodb.client.MongoDatabase;
import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSBuckets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;

/**
 * @program: shop
 * @description: mongodb配置类
 * @author: zhuzh
 * @create: 2019-11-28 09:32
 **/
@Configuration
public class MongodbConfig {
	@Autowired
	private MongoDbFactory mongoDbFactory;
	@Autowired
	private GridFSBucket gridFSBucket;

	@Bean
	public GridFSBucket getGridFSBucket() {
		MongoDatabase db = mongoDbFactory.getDb();
		return GridFSBuckets.create(db);
	}
}
